import Vue from "vue"
import Vuex from "vuex"
import utils from "../assets/js/utils"

Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        activeMenuName: "user",
        siteInfos: {},
        scale: 1,
        kitchenplayVideoList: [],
        winSize: {
            winH: 500,
            winW: 1000,
        },
        mapType: utils.getStorage("MAP_TYPE") || "amap",
    },
    mutations: {
        setActiveMenuName: (state, activeMenuName) => {
            state.activeMenuName = activeMenuName
        },
        setSiteInfos: (state, siteInfos) => {
            state.siteInfos = siteInfos
            utils.setStorage("SITE_INFOS", siteInfos)
        },
        setScale: (state, scale) => {
            state.scale = scale
        },
        setKitchenplayVideoList: (state, value) => {
            state.kitchenplayVideoList = value
        },
        setWinSize: (state, value) => {
            state.winSize = value
        },
        setMapType: (state, value) => {
            state.mapType = value
            utils.setStorage("MAP_TYPE", value)
        },
    },
    getters: {
        hasEditPermission(state) {
            return state.siteInfos.exhibitionType != 1
        },
    },
    actions: {},
    modules: {},
})
